﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：吕海乐 
    //
    // 文件名：FeedBack.aspx.cs
    // 文件功能描述：消息管理：反馈列表
    // 创建标识：吕海乐2009-5-20
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
// 审核时间：
// 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;

namespace HZ.DrugTrade.Web.Enterprise.MessageMange
{
    public partial class FeedBackList : BasePage
    {
        public FeedBackList()
        {
            this.ModuleNo = "";
        }

        IBLL_Message im = Factory.BLL_Message();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ListItem item = new ListItem();
                item.Text = Constants.ALL_ITEM_TEXT;
                item.Value = Constants.ALL_ITEM_VALUE;
                ddlStatus.Items.Insert(0, item);
                ddlStatus.DataBind();

                StoreCondition();
                BindFeedBack();
            }
        }

        /// <summary>
        /// 存储查询条件
        /// </summary>
        /// <returns></returns>
        private Model.Query.FeedBack StoreCondition()
        {
            Model.Query.FeedBack qFeedBack = new HZ.DrugTrade.Model.Query.FeedBack();
            //qFeedBack.Reciever = CurrentAccount.GetUser().Org.OrgID;
            qFeedBack.SendTimeFrom = new HZ.Common.ConvertHelper(txtSendTimeFrom.Text.Trim()).ToDateTime;
            qFeedBack.SendTimeTo = new HZ.Common.ConvertHelper(txtSendTimeTo.Text.Trim()).ToDateTime;
            qFeedBack.Status = new HZ.Common.ConvertHelper(ddlStatus.SelectedItem.Value).ToInt32;
            qFeedBack.SortFields = "SendTime DESC";
            ViewState["qFeedBack"] = qFeedBack;
            return (Model.Query.FeedBack)ViewState["qFeedBack"];
        }
        /// <summary>
        /// 获取查询条件
        /// </summary>
        /// <returns></returns>
        private Model.Query.FeedBack GetCondition()
        {
            Model.Query.FeedBack qFeedBack = (Model.Query.FeedBack)ViewState["qFeedBack"];
            return qFeedBack;
        }
        /// <summary>
        /// 绑定符合条件的反馈信息
        /// </summary>
        private void BindFeedBack()
        {
            int totalCount;
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            Model.Query.FeedBack qFeedBack = (Model.Query.FeedBack)ViewState["qFeedBack"];
            IList<Model.View.FeedBack> lstFeedBack = im.GetFeedBack_Sender(qFeedBack, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            AspNetPager1.RecordCount = totalCount;
            gvwFeedBack.DataSource = lstFeedBack;
            gvwFeedBack.DataBind();
        }


        /// <summary>
        /// 绑定反馈的状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvwFeedBack_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Literal ltrStatus = e.Row.FindControl("ltrStatus") as Literal;
                if (ltrStatus.Text == "0")
                {
                    ltrStatus.Text = "未读";
                }
                else if (ltrStatus.Text == "1")
                {
                    ltrStatus.Text = "已读";
                }
                else if (ltrStatus.Text == "2")
                {
                    ltrStatus.Text = "已回复";
                }
            }
        }

        /// <summary>
        /// 执行查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            StoreCondition();
            BindFeedBack();
        }

        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            StoreCondition();
            BindFeedBack();
        }
    }
}
